<?php
//加载数据库配置文件
  
//加载类
function autoload_class()
{
    $path = ADMINROOT.'program'.DIRECTORY_SEPARATOR.'*.php';
    //if(empty ($path)) $path = _LIB."autoclass".DIRECTORY_SEPARATOR;   //如果目录为空
    //$path.="*.class.php";
    $class_all=glob($path);
    if(!empty($class_all) && is_array($class_all)){
        foreach ($class_all as $filename) {
            if(file_exists($filename)){
                include($filename);
                //$classn = new $filename;
                //return $classn;
            }
        }
    }
}

//使用smarty
define('SMARTY_DIR',ROOT.'program'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR);
require(SMARTY_DIR.'Smarty.class.php');

class admintemp extends Smarty{
    public function __construct() {
        parent::__construct();
        $this->caching = false;
        $this->config_dir = ADMINROOT.'skis'.DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR;
        $this->template_dir = ADMINROOT.'skis'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
        $this->compile_dir = ADMINROOT.'skis'.DIRECTORY_SEPARATOR.'compile'.DIRECTORY_SEPARATOR;
        $this->cache_dir = ADMINROOT.'skis'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;

        $this->left_delimiter = "{";
        $this->right_delimiter = "}";
        
        //获取协议
        $pro = explode("/",$_SERVER["SERVER_PROTOCOL"]);
        $pro = strtolower($pro[0].'://'.$_SERVER["SERVER_NAME"].'/admin');
        
        define('WEBPATH', $pro);
        $this->assign("webpathskis", WEBPATH.'/skis/templates/');
        $this->assign("webpaths", WEBPATH.'/');
        $pro = explode("/",$_SERVER["SERVER_PROTOCOL"]);
        $pro = strtolower($pro[0].'://'.$_SERVER["SERVER_NAME"]);
        $this->assign("webpathroot", $pro.'/');
        
    }
}

//加载类
autoload_class();
require ROOT.'program'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'db.php';
//设置页面编码为 utf-8
header('Content-type: text/html; charset=utf-8');

?>
